<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>${title}</title>
		<link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/common.css'/>"/>
		<link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/jquery.autocomplete.css'/>" />
		<script type="text/javascript" src="<c:url value='/resource/js/jquery-1.7.2.min.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery.autocomplete.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/artdialog.js?skin=${sys_theme}'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery.form.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/iframetools.js'/>"></script>	
		<script type="text/javascript" src="<c:url value='/resource/js/common.js'/>"></script>
		<script type="text/javascript">
			$(function(){
				//$("#deptName").bind("click",openTree);
				//$("#dept2Name").bind("click",openSubTree);
				if("${dept.deptId}".indexOf("00")==4)
				{
			        if("${dept.deptId}".length!=8)
			        {
				        $("#dept2Name").val("${dept.alias}");
				    }
				}
				else
				{
					if("${dept.deptId}".length!=6)
					{
				        $("#dept2Name").val("${dept.alias}");
				    }
				}
			});
			//决断是否为空
			function isEmpty(id,msg){
				if("" == $(id).val().replace(/(^\s*)|(\s*$)/g, "")){
					art.dialog.tips(msg);
					$(id).focus();
					$(id).select();
					return false;
				}
				return true;
			}
			//检查表单
			function checkForm(){
				return isEmpty("#policeNum","请输入警号！")&&
				isEmpty("#name","请输入姓名！")
			}
		
			
			function openTree(){
				art.dialog.open("<c:url value='/common/open_radio_tree.jsp'/>",{
					title:"选择部门",
					lock : true,
					fixed : true,
					ok: function () {
						var iframe = this.iframe.contentWindow;
						if(!iframe.document.body){
							art.dialog.tips("正在加载，请稍候...",1500);
							return false;
						}
						iframe.sub_form();
						return false;
					},
					cancel: true
				});
			}
			function openSubTree(){
				var dw1=$("#deptId").val().substring(0, 8);
				art.dialog.open("<c:url value='/common/open_dept_tree.jsp?dw1="+dw1+"'/>",{
					title:"选择部门",
					lock : true,
					fixed : true,
					ok: function () {
						var iframe = this.iframe.contentWindow;
						if(!iframe.document.body){
							art.dialog.tips("正在加载，请稍候...",1500);
							return false;
						}
						iframe.sub_form();
						return false;
					},
					cancel: true
				});
			}
			
			function submitForm(pageIndex){
				if(checkForm()){
					top.mask();
					$("#query_form").ajaxSubmit({
						type:"post",
						dataType:"json",
						success:function(data){
							top.unmask();
							switch(parseInt(data.result)){
								case 1:
									art.dialog.tips("新增失败，警号重复！",3000);
									break;
								default:
									art.dialog.tips("新增成功！",1.5);
								window.setTimeout(function(){
									window.parent.frames["ifrm_data"].frames["ifrm_deptlist"]._goto(pageIndex);
									art.dialog.close();
								},1500);
									break;
							}
						},
						error:function(){
							top.unmask();
							art.dialog.tips("新增失败！",1.5);
						}
					});
				}
			}
		</script>
	</head>
	<body  style="margin:0 auto;overflow:hidden;">
		<form method="post" id="query_form" action="<c:url value='/user/saveadd.json'/>" style="margin:0px;padding:0px;width:350px;">
			<table style="margin:0px;padding:0px;">
				<tr>
					<td class="td_tit">警号:</td>
					<td>
					<input style="width:254px" maxlength="10" onblur="this.value=this.value.replace(/\s/g,'');" id="policeNum" type="text" name="policeNum" title="警号输入后不可更改!"></input><span style="color:red">*</span>
					<input name="userId" id="personid" type="hidden"/>
					</td>
				</tr>
				<tr>
					<td class="td_tit">姓名:</td>
					<td><input style="width:254px" maxlength="10" onblur="this.value=this.value.replace(/\s/g,'');" id="name" type="text" name="name"></input><span style="color:red">*</span></td>
				</tr>
				<tr>
					<td class="td_tit">所属单位:</td>
					<td>
						<input readonly="readonly" id="deptName" type="text" value="${deptTop.alias}" style="width:254px;cursor:pointer;" title="点击选择部门"/>
						<input type="hidden" id="deptId" name="deptId" value="${dept.deptId }"/>
					</td>
				</tr>
				<tr>
					<td class="td_tit">部门:</td>
					<td><input style="width:254px" maxlength="50" onblur="this.value=this.value.replace(/\s/g,'');" id="dept2Name" type="text" name="dept2Name"></input></td>
				</tr>
				<tr>
					<td class="td_tit">身份证:</td>
					<td><input style="width:254px" maxlength="18"   id="idCard" type="text" name="idCard"></input></td>
				</tr>
				<tr>
					<td class="td_tit">联系电话:</td>
					<td><input style="width:254px"  id="tel" type="text" name="tel"></input></td>
				</tr>
			</table>
		</form>
	</body>
</html>